:- 
 import "%%/lib/client.sl"  
# 
web.books.ssp :- 
	www "<html><head>",  
style,  
	www "<script>",  
	wnl, 
	www "	<!--",  
	wnl, 
	www "	function ajaxPost (url, vars, callbackFunc) {",  
	wnl, 
	www "		var request = new XMLHttpRequest ();",  
	wnl, 
	www "		request.open ('POST', url, true);",  
	wnl, 
	www "		request.setRequestHeader ('Content-Type',",  
	wnl, 
	www "			'application/x-www-form-urlencoded');",  
	wnl, 
	www "		request.setRequestHeader ('Content-Length', vars.length);",  
	wnl, 
	www "		request.setRequestHeader ('Connection', 'close');",  
	wnl, 
	www "		request.onreadystatechange = function () {",  
	wnl, 
	www "			if(request.readyState == 4 && request.status == 200 &&",  
	wnl, 
	www "				request.responseText)",  
	wnl, 
	www "				callbackFunc (request.responseText);",  
	wnl, 
	www "		};",  
	wnl, 
	www "		request.send (vars);",  
	wnl, 
	www "	}",  
	wnl, 
	www "	function listBooks () {",  
	wnl, 
	www "		ajaxPost ('book.list', '', gotBooks);",  
	wnl, 
	www "	}",  
	wnl, 
	www "	function gotBooks (result) {",  
	wnl, 
	www "		books = eval ('(' + result + ')');",  
	wnl, 
	www "		var i, out = '';",  
	wnl, 
	www "		for(i in books)",  
	wnl, 
	www "			out += '<input type=checkbox name=cb>' + books[i] + '<br>';",  
	wnl, 
	www "		document.getElementById ('books').innerHTML = out;",  
	wnl, 
	www "		return false;",  
	wnl, 
	www "	}",  
	wnl, 
	www "	function addBookOnSubmit () {",  
	wnl, 
	www "		element = document.getElementById ('message');",  
	wnl, 
	www "		ajaxPost (",  
	wnl, 
	www "			'book.add',",  
	wnl, 
	www "			'name=' + encodeURIComponent (document.addForm.name.value),",  
	wnl, 
	www "			function (result) {",  
	wnl, 
	www "				element.innerHTML = result;",  
	wnl, 
	www "				listBooks ();",  
	wnl, 
	www "			}",  
	wnl, 
	www "		);",  
	wnl, 
	www "		document.addForm.name.value = '';",  
	wnl, 
	www "		return false;",  
	wnl, 
	www "	}",  
	wnl, 
	www "	//-->",  
	wnl, 
	www "</script></head>",  
	wnl, 
	www "<body onload='listBooks ();'>",  
	wnl, 
	www "	Books in repository:<p>",  
	wnl, 
	www "	<div id=books>&nbsp;</div><br>",  
	wnl, 
	www "	<p>",  
	wnl, 
	www "	<form name=addForm action='#' method=post",  
	wnl, 
	www "		onSubmit=""return addBookOnSubmit ();"">",  
	wnl, 
	www "		<input name=name autocomplete=off title=Name value=''>",  
	wnl, 
	www "		<input type=submit value=Add>",  
	wnl, 
	www "	</form>",  
	wnl, 
	www "	<div id=message>&nbsp;</div>",  
	wnl, 
	www "</body></html>",  
	wnl, 
# 
 web.book.list  :- 
	www "	{",  
	wnl, 
	www "	",  
forall (remote.search (BOOK .id .name)) (  
	wnl, 
	www "		",  
	www  .id , 
	www ": """,  
	www  .name , 
	www """,",  
	wnl, 
	www "	",  
),  
	wnl, 
	www "	}",  
	wnl, 
# 
 web.book.add  :- 
	www "	",  
		get.form "name" .name, 
		remote.queryOnce (newBook (BOOK . .name)), 
	 
	wnl, 
	www "	<b>Book """,  
	www  .name , 
	www """ added.</b>",  
	wnl, 
# 
 web.book.delete  :- 
	www "	",  
		get.form "name" .name, remote.delete (BOOK . .name), 
	 
	wnl, 
	www "	<b>Book """,  
	www  .name , 
	www """ removed.</b>",  
	wnl, 
# 
 remote.server "localhost" 5151  
# 
web.form.ssp :- 
	www "<html>",  
	wnl, 
	www "	<head>",  
style,  
	www "</head>",  
	wnl, 
	www "	<body>",  
	wnl, 
	www "		<form name=loginForm action='submit.ssp' method=post>",  
	wnl, 
	www "			<input name=input autocomplete=off title=User value=''>",  
	wnl, 
	www "			<input type=submit value=Submit>",  
	wnl, 
	www "		</form>",  
	wnl, 
	www "	</body>",  
	wnl, 
	www "</html>",  
	wnl, 
# 
 web.submit.ssp  :- 
	www "<html>",  
	wnl, 
	www "	<head>",  
	wnl, 
	www "		<title>singlog server page</title>",  
	wnl, 
	www "		",  
style,  
	wnl, 
	www "	</head>",  
	wnl, 
	www "	<body>Hello Worldwide Web~~~</body>",  
	wnl, 
	www "	",  
		(get DATA .prev; .prev = ""), 
		(get.posted .posted; .posted = ""), 
		(get.form "input" .input; .input = ""), 
		remote.query (temporary .temp), 
	 
	wnl, 
	www "	<p>Invocation = ",  
	www  .temp , 
	wnl, 
	www "	<p>Previous = ",  
	www  .prev , 
	wnl, 
	www "	<p>Posted = ",  
	www  .posted , 
	wnl, 
	www "	<p>Input = ",  
	www  .input , 
	wnl, 
	www "	",  
		set DATA .input, 
	 
	wnl, 
	www "</html>",  
	wnl, 
# 
 style  :- 
	www "<style>body { background-color:#202020; color: #888888; }</style>",  
	wnl, 
# 
 remote.server "localhost" 5151  
# 
